﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HSDc.RingleFlow.Api.Kernel;
using HSDc.RingleFlow.Api.Rule;
using HSDc.RingleFlow.Kernel.Exception;

namespace HSDc.RingleFlow.Kernel
{
    class Activity
    {
        protected string _id;
        protected string _name;
        protected IRule _rule;
        protected List<Transition> outboundTransitions = new List<Transition>();
        protected List<Transition> inboundTransitions = new List<Transition>();
        protected Swimlane _BelongSwimlane;
        public Activity(string _id) : this(_id, string.Empty, null, null) { }
        public Activity(string _id, string _name, IRule _rule, Swimlane _BelongSwimlane)
        {
            this._id = _id;
            this._name = _name;
            this._rule = _rule;
            this._BelongSwimlane = _BelongSwimlane;
        }
        virtual internal bool CanExecute
        {
            get { return false; }
        }
        internal string Name
        {
            get { return _name; }
        }
        internal string Id
        {
            get { return _id; }
        }
        internal IRule Rule
        {
            get { return _rule; }
        }

        internal Swimlane BelongSwimlane
        {
            get { return _BelongSwimlane; }
        }

        internal List<Transition> OutboundTransitions
        {
            get { return outboundTransitions; }
            set { outboundTransitions = value; }
        }

        internal virtual void AddOutboundTransition(Transition _transition)
        {
            if (outboundTransitions.Count > 0)
                throw new KernelException("Could'nt add transition when transition exist");
            outboundTransitions.Add(_transition);
        }

        internal virtual void AddInboundTransition(Transition _transition)
        {
        }

        internal virtual List<Transition> InboundTransitions
        {
            get { return inboundTransitions; }
            set { inboundTransitions = value; }
        }
    }
}
